﻿package  {
	
	import flash.display.MovieClip;
	import flash.events.Event;
	import flash.events.MouseEvent;
	
	//class implements simple drag and drop
	//for demonstration purposes it also communicates with the TextPanel singleton
	
	public class DraggableItem extends MovieClip{

		public function DraggableItem() {
			// constructor code
			trace ("constructor for draggable item");
			this.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownListener);
			this.addEventListener(MouseEvent.MOUSE_UP, mouseUpListener);
		}
		
		
		public function mouseDownListener(e:Event)
		{
		this.startDrag();
		//note how we access the TextPanel component via its static getInstance functionh
		TextPanel.getInstance().textField.text="oi, get off me";
		}
		
		public function mouseUpListener(e:Event)
		{
		this.stopDrag();
		//note how we access the TextPanel component via its static getInstance functionh
		TextPanel.getInstance().textField.text="ah, that's better";
		}

	}
	
}
